class AdminController < Admin
  def index
    @artists = Artist.find(:all)
    @artworks = Artwork.find(:all)
    @page_title = l(:admin, :title)
  end
  
  def admin_list
    if current_user.has_role?("superadmin")
      @regions = Region.find(:all) 
    else
      @regions = current_user.regions.collect()
    end
    @page_title = l(:admin, :admins)
  end
  
  def add_admin
     @region = Region.find(params[:region_id])
     @user = User.find_by_email(params[:promote_admin_email])
     if @user and @region
       @user.add_region_admin(@region);
       flash[:notice] = @user.name + " is now an admin for " + @region.name
     else
       flash[:error] = "There is no user with the email " + params[:promote_admin_email]
     end
     redirect_to :back
 end
 
 def remove_admin
  @region = Region.find(params[:region_id])
  @user = User.find_by_id(params[:user_id])
  if @user and @region
    @user.remove_region_admin(@region);
  end
  flash[:notice] = @user.name + " is no longer an admin for " + @region.name
  redirect_to :back
 end
end
